const spdy = require('spdy')
const express = require('express')
const path = require('path')
const fs = require('fs')

const http2Api = express.Router()

http2Api.get('/http2Test', (req, res) => {
  console.log('http2 http2Test :----> ')
    res.status(200).json({message: 'ok'})
})

const options = {
    key: fs.readFileSync(__dirname + '/server.key'),
    cert:  fs.readFileSync(__dirname + '/server.crt'),
    spdy: {
        protocols: ['h2']
      }
}

let server = spdy.createServer(options, http2Api)

// console.log('http2 createServer :----> ')

server.on('connect',(req,socket,heade)=>{
  console.log('http2 connect :----> ')
})
server.listen(9527,()=>{
  console.log('http2 listen :----> ')
})
module.exports = http2Api